import React, { memo, useState } from 'react'
 import {deng} from './api/shop'
 import {useNavigate, useRoutes} from 'react-router-dom'
 import route from './route'
const App = memo(() => {
  const [value1,setv1]=useState('')
  const [value2,setv2]=useState('')
  const navigate=useNavigate()
  
 return (
   <div>
       <input type="text" value={value1}  onChange={(e)=>{setv1(e.target.value)}}/>
       <input type="text" value={value2}  onChange={(e)=>{setv2(e.target.value)}}/>
       <button onClick={async()=>{
        let res=await deng({username:value1,password:value2})
        console.log(res.data.data.token);
            //  判断信息
           if( res.data.success){localStorage.setItem('token',res.data.data.token);navigate('/Home')}
       }}>点击登录</button>
       {useRoutes(route)}
   </div>
 )
})

export default App